import matplotlib as mtplb
import numpy as np
import analyse.parameter_simulation as ps


class parameter_plot:
    #==================图像基本参数====================
    def __init__(self, para) -> None:
        self.peak = para.laser_E * 1.15
        self.vmax = self.peak
        self.vmin = -self.peak
        self.levels = 10
        self.shading = 'gouraud'
        self.cmap = 'bwr'
        self.method = 'pcolormesh'
        #画图参数设置
        self.aspect = 'auto'
        #图示
        self.title = 'E-x'
        self.xlabel = 'x($\lambda $)'
        self.ylabel = 'y($\lambda $)'
        self.Elabel = 'E($m_ec\omega_pe^{-1} $)'
        #归一化设置
        self.xunit = para.laser_wavelength  #位置x的归一化
        self.yunit = para.laser_wavelength  #位置y的归一化，一般用于二维图
        self.Eunit = ps.me * ps.c * para.laser_frequency / ps.qe  #电场归一化
        self.unit = 1  #画图时默认使用的程度单位
        self.norm = mtplb.colors.Normalize(vmin=self.vmin / self.Eunit,
                                           vmax=self.vmax / self.Eunit)

    def set_recover(self, para):
        '''
        使得pp参数复原为原本的依据para生成的参数
        '''
        self.__init__(para)

    def set_peak(self, peak, vmax=None, vmin=None):
        self.peak = peak
        if (vmax == None):
            self.vmax = peak * 1.15
        else:
            self.vmax = vmax
        if (vmin == None):
            self.vmin = -peak * 1.15
        else:
            self.vmin = vmin
        self.norm = mtplb.colors.Normalize(vmin=self.vmin / self.Eunit,
                                           vmax=self.vmax / self.Eunit)
